﻿using System;
using System.Runtime.InteropServices.Automation;

namespace ComToolkit
{
    /// <summary>
    /// Provides information about, and means to manipulate, the current environment.
    /// </summary>
    public static class Environment
    {
        //TODO: Lots of cool stuff to implement here: http://msdn.microsoft.com/en-us/library/fd7hxfdd%28VS.85%29.aspx
        private static dynamic shell;
        private static dynamic network;
        static Environment()
        {
            //http://msdn.microsoft.com/en-us/library/3cc5edzd%28VS.85%29.aspx
            shell = AutomationFactory.CreateObject("Wscript.Shell");
            network = AutomationFactory.CreateObject("WScript.Network");
        }
        /// <summary>
        /// Gets or sets the fully qualified path of the current working directory.
        /// </summary>
        public static string CurrentDirectory
        {
            get { return shell.CurrentDirectory; }
            set { shell.CurrentDirectory = value; }
        }
        /// <summary>
        /// Property contains a string value indicating the name of the computer system.
        /// </summary>
        public static string MachineName
        {
            get { return network.ComputerName; }
        }
        /// <summary>
        /// Gets the network domain name associated with the current user.
        /// </summary>
        public static string UserDomainName
        {
            get { return network.UserDomain; }
        }
        /// <summary>
        /// Gets the user name of the person who is currently logged on to the Windows
        ///operating system.
        /// </summary>
        public static string UserName
        {
            get { return network.UserName; }
        }
    }
}
